package com.ocm.tourism.core.jdbc.rowmapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.ocm.tourism.core.domain.Business;
import com.ocm.tourism.core.domain.BusinessType;
import com.ocm.tourism.core.domain.FileInfo;
public class BusinessViewestRowMapper implements RowMapper<Business>{

   public Business mapRow(ResultSet resultSet, int rownumber) throws SQLException {
      Business business = new Business();
      business.setId(resultSet.getLong("bus_id"));
      business.setAddress(resultSet.getString("bus_address"));
      business.setDescription(resultSet.getString("bus_desc"));
      business.setFax(resultSet.getString("bus_fax"));
      business.setMobilephone(resultSet.getString("bus_mobile"));
      business.setHomephone(resultSet.getString("bus_homephone"));
      business.setName(resultSet.getString("bus_name"));
      business.setBusinessType(BusinessType.getBusinessType(resultSet.getString("bus_type")));

      FileInfo avatar = new FileInfo();
      avatar.setId(resultSet.getLong("fi_id"));
      avatar.setAbsolutePath(resultSet.getString("fi_absolutepath"));
      avatar.setExtension(resultSet.getString("fi_extension"));
      avatar.setFileDetail(resultSet.getString("fi_fileDetail"));
      avatar.setMimetypes(resultSet.getString("fi_minetypes"));
      avatar.setName(resultSet.getString("fi_name"));

      business.setAvatar(avatar);
      return business;
   }
}
